package com.heima.comment.controller;


import com.heima.comment.service.ApCommentRepayService;
import com.heima.comment.service.ApCommentService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.comment.dtos.ApCommentRepayDto;
import com.heima.model.comment.dtos.CommentRepayLikeDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.comment.pojos.ApCommentRepay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/comment_repay")
public class ApCommentRepayController {


    @Autowired
    private ApCommentRepayService commentRepayService;

    /**
     * 保存评论回复
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentRepaySaveDto dto){
       return commentRepayService.save(dto);
    }

    /**
     * 查询评论回复列表
     * @param commentRepaySaveDto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult<List<ApCommentRepayDto>> load(@RequestBody CommentRepaySaveDto commentRepaySaveDto){
       return commentRepayService.load(commentRepaySaveDto);
    }


    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentRepayLikeDto dto){
        return commentRepayService.like(dto);
    }

}
